package com.wwt.blog.handler;

import com.wwt.blog.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice  //对所有添加了Controller注解的方法进行拦截处理  AOP的实现
@ResponseBody
public class AllExceptionHandler {
    @ExceptionHandler(Exception.class)  //处理Exception类型的异常
    public Result doException(Exception exception){
        exception.printStackTrace();  //简单的控制台打印异常
        return Result.result_fail(999,"系统异常!");
    }
}